<template>
  <div>
    <el-form ref="form" :model="form" :rules="rules" label-width="80px">
      <el-form-item label="关联产品" prop="pid">
        <el-input v-model="form.pid" placeholder="请输入关联产品"/>
      </el-form-item>
      <el-form-item label="适配OS" prop="paOs">
        <el-select v-model="form.paOs" placeholder="请选择适配OS">
          <el-option
            v-for="dict in dict.type.audition_os"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="适配时间" prop="paTime">
        <el-date-picker clearable
                        v-model="form.paTime"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="请选择适配时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="适配OS类型" prop="paType">
        <el-select v-model="form.paType" placeholder="请选择适配OS类型">
          <el-option
            v-for="dict in dict.type.auditiing_os_type"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="适配状态" prop="paState">
        <el-select v-model="form.paState" placeholder="请选择适配状态">
          <el-option
            v-for="dict in dict.type.auditing_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="适配OS版本" prop="paVersion">
        <el-input v-model="form.paVersion" placeholder="请输入适配OS版本"/>
      </el-form-item>
      <el-form-item label="兼容等级" prop="paLevel">
        <el-select v-model="form.paLevel" placeholder="请选择兼容等级">
          <el-option
            v-for="dict in dict.type.compatibility_level"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="OS小版本" prop="paMinVersion">
        <el-input v-model="form.paMinVersion" placeholder="请输入OS小版本"/>
      </el-form-item>
      <el-form-item label="认证状态" prop="paAuthenticationStatus">
        <el-select v-model="form.paAuthenticationStatus" placeholder="请选择认证状态">
          <el-option
            v-for="dict in dict.type.certification_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="适配平台" prop="paPlatform">
        <el-select v-model="form.paPlatform" placeholder="请选择适配平台">
          <el-option
            v-for="dict in dict.type.adaptation_platform"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="收费/免费" prop="paCost">
        <el-input v-model="form.paCost" placeholder="请输入收费/免费"/>
      </el-form-item>
      <el-form-item label="适配CPU型号" prop="paCpu">
        <el-select v-model="form.paCpu" placeholder="请选择适配CPU型号">
          <el-option
            v-for="dict in dict.type.adapted_cpu_model"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="上架情况" prop="paListing">
        <el-select v-model="form.paListing" placeholder="请选择上架情况">
          <el-option
            v-for="dict in dict.type.auditing_listing"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="备注" prop="paRemark">
        <el-input v-model="form.paRemark" type="textarea" placeholder="请输入内容"/>
      </el-form-item>
      <el-form-item label="适配验证情况" prop="paValidate">
        <el-select v-model="form.paValidate" placeholder="请选择适配验证情况">
          <el-option
            v-for="dict in dict.type.adaptation_verification_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="安装使用文档" prop="paUsingDocuments">
        <file-upload v-model="form.paUsingDocuments"/>
      </el-form-item>
      <el-form-item label="适配产品安装包" prop="paInstallPackage">
        <file-upload v-model="form.paInstallPackage"/>
      </el-form-item>
      <el-form-item label="删除标志" prop="delFlag">
        <el-input v-model="form.delFlag" placeholder="请输入删除标志"/>
      </el-form-item>
      <el-form-item label="备注" prop="remark">
        <el-input v-model="form.remark" placeholder="请输入备注"/>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="submitForm">确 定</el-button>
      <el-button @click="cancel">取 消</el-button>
    </div>
  </div>
</template>

<script>
import AddMixin from "@/minixs/add"
import request from "@/utils/request";

export default {
  name: "add",
  mixins: [AddMixin],
  dicts: ['audition_os', 'adapted_cpu_model', 'compatibility_level', 'adaptation_verification_status', 'adaptation_platform', 'auditing_status', 'auditiing_os_type', 'auditing_listing', 'certification_status'],
  data() {
    return {
      // 表单数据
      form: {
        id: null,
        pid: null,
        paOs: null,
        paTime: null,
        paType: null,
        paState: null,
        paVersion: null,
        paLevel: null,
        paMinVersion: null,
        paAuthenticationStatus: null,
        paPlatform: null,
        paCost: null,
        paCpu: null,
        paListing: null,
        paRemark: null,
        paValidate: null,
        paUsingDocuments: null,
        paInstallPackage: null,
        paStatus: null,
        delFlag: null,
        createBy: null,
        updateBy: null,
        createTime: null,
        updateTime: null,
        remark: null
      },
      // 表单校验
      rules: {
        pid: [
          {required: true, message: "关联产品不能为空", trigger: "blur"}
        ],
        paOs: [
          {required: true, message: "适配OS不能为空", trigger: "change"}
        ],
        paTime: [
          {required: true, message: "适配时间不能为空", trigger: "blur"}
        ],
        paType: [
          {required: true, message: "适配OS类型不能为空", trigger: "change"}
        ],
        paState: [
          {required: true, message: "适配状态不能为空", trigger: "change"}
        ],
        paVersion: [
          {required: true, message: "适配OS版本不能为空", trigger: "blur"}
        ],
        paLevel: [
          {required: true, message: "兼容等级不能为空", trigger: "change"}
        ],
        paMinVersion: [
          {required: true, message: "OS小版本不能为空", trigger: "blur"}
        ],
        paAuthenticationStatus: [
          {required: true, message: "认证状态不能为空", trigger: "change"}
        ],
        paPlatform: [
          {required: true, message: "适配平台不能为空", trigger: "change"}
        ],
        paCost: [
          {required: true, message: "收费/免费不能为空", trigger: "blur"}
        ],
        paCpu: [
          {required: true, message: "适配CPU型号不能为空", trigger: "change"}
        ],
        paListing: [
          {required: true, message: "上架情况不能为空", trigger: "change"}
        ],
        paRemark: [
          {required: true, message: "备注不能为空", trigger: "blur"}
        ],
        paValidate: [
          {required: true, message: "适配验证情况不能为空", trigger: "change"}
        ],
        paUsingDocuments: [
          {required: true, message: "安装使用文档不能为空", trigger: "blur"}
        ],
        paInstallPackage: [
          {required: true, message: "适配产品安装包不能为空", trigger: "blur"}
        ],
      }
    }
  },
  methods: {
    // 保存数据
    save() {
      request({
        url: '/info/adaptation',
        method: 'post',
        data: this.form
      }).then(response => {
        this.$modal.msgSuccess("新增成功");
        this.$emit("reload")
        this.cancel();
      });
    },
  }
};
</script>
